<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <title>已安装插件的用户查询</title>
    <!-- Bootstrap CSS -->
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
    <!-- 自定义 CSS -->
    <link href="{{ url_for('static', filename='css/styles.css') }}" rel="stylesheet">
</head>
<body>
    <!-- 导航栏 -->
    <nav class="navbar navbar-expand-lg navbar-dark bg-dark fixed-top">
        <div class="container-fluid">
            <a class="navbar-brand" href="#">DCO管理系统</a>
            <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav" 
                aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
                <span class="navbar-toggler-icon"></span>
            </button>
            <div class="collapse navbar-collapse" id="navbarNav">
                <ul class="navbar-nav ms-auto">
                    <!-- 事件管理菜单项 -->
                    <li class="nav-item">
                        <a class="nav-link" href="{{ url_for('view_events') }}">事件管理</a>
                    </li>
                    <!-- 用户管理菜单项 -->
                    <li class="nav-item">
                        <a class="nav-link" href="{{ url_for('view_installed_users') }}">用户管理</a>
                    </li>
                    <!-- 其他菜单项（如果有） -->
                    <!-- <li class="nav-item">...</li> -->
                </ul>
            </div>
        </div>
    </nav>    

    <!-- 主容器 -->
    <div class="container" style="margin-top: 80px;">
        <h1 class="mb-4 text-center">已安装插件的用户查询</h1>

        <!-- 过滤表单 -->
        <form method="get" action="/view_installed_users" class="filter-form">
            <div class="row g-3">
                <div class="col-md-3">
                    <label for="login" class="form-label">Git 用户名</label>
                    <input type="text" class="form-control" id="login" name="login" placeholder="请输入用户名" value="{{ request.args.get('login', '') }}">
                </div>
                <div class="col-md-3">
                    <label for="email" class="form-label">用户邮箱</label>
                    <input type="email" class="form-control" id="email" name="email" placeholder="请输入邮箱" value="{{ request.args.get('email', '') }}">
                </div>
                <div class="col-md-3">
                    <label for="plugin_installed" class="form-label">插件已安装</label>
                    <select class="form-select" id="plugin_installed" name="plugin_installed">
                        <option value="">全部</option>
                        <option value="1">已安装</option>
                    </select>
                </div>
                <div class="col-md-3">
                    <button type="submit" class="btn btn-primary mt-4">查询</button>
                </div>
            </div>
        </form>

        <!-- 查询结果展示 -->
        <table class="table table-striped mt-4">
            <thead>
                <tr>
                    <th scope="col">Git 用户名</th>
                    <th scope="col">邮箱</th>
                    <th scope="col">姓名</th>
                    <th scope="col">插件安装状态</th>
                    <th scope="col">操作</th>
                </tr>
            </thead>
            <tbody>
                {% for user in users %}
                    <tr>
                        <td>{{ user.login }}</td>
                        <td>{{ user.email }}</td>
                        <td>{{ user.name }}</td>
                        <td>
                            <span class="badge bg-success">已安装</span>
                        </td>
                        <td>
                            <a href="{{ url_for('view_user_details', user_id=user.id) }}">查看详情</a>
                        </td>
                    </tr>
                {% endfor %}
            </tbody>
        </table>

        <!-- 分页 -->
        <nav aria-label="Page navigation example">
            <ul class="pagination justify-content-center">
                {% if prev_page %}
                    <li class="page-item">
                        <a class="page-link" href="{{ url_for('view_installed_users', page=prev_page) }}" aria-label="Previous">
                            <span aria-hidden="true">&laquo;</span>
                        </a>
                    </li>
                {% endif %}
                <li class="page-item disabled">
                    <span class="page-link">第 {{ current_page }} 页，共 {{ total_pages }} 页</span>
                </li>
                {% if next_page %}
                    <li class="page-item">
                        <a class="page-link" href="{{ url_for('view_installed_users', page=next_page) }}" aria-label="Next">
                            <span aria-hidden="true">&raquo;</span>
                        </a>
                    </li>
                {% endif %}
            </ul>
        </nav>
    </div>

    <!-- Bootstrap JS -->
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
</body>
</html>
